<template>
  <the-table
    :columns="columns"
    uri="/a/callback-buys"
    ref="table"
    :slots="['callback_ok', 'action']"
  >
    <span slot="action" slot-scope="{ row }">
      <a
        v-if="!row.callback_ok && row.state !== 'fail'"
        class="ant-dropdown-link"
        @click="send(row)"
        ><a-icon :type="row.loading ? 'loading' : 'rocket'" /> 发送
      </a>
    </span>
    <span slot="callback_ok" slot-scope="{ row }">
      {{ row.callback_ok ? '成功' : '' }}
    </span>
  </the-table>
</template>
<script>
import theTable from '@/components/theTable.vue'

const columns = [
  {
    title: '商户',
    dataIndex: 'seller.username',
    searchAble: true,
  },
  {
    title: '订单号',
    dataIndex: 'id',
    searchAble: true,
  },
  {
    title: '商户订单号',
    dataIndex: 'transaction_id',
    searchAble: true,
  },
  {
    title: '通知URL',
    dataIndex: 'seller.notify_url',
  },

  {
    title: '回调执行次数',
    dataIndex: 'callback_num',
    width: 120,
  },
  {
    title: '回调结果',
    dataIndex: 'callback_ok',
    scopedSlots: { customRender: 'callback_ok' },
  },
  {
    title: '操作',
    key: 'action',
    scopedSlots: { customRender: 'action' },
    width: 120,
  },
]

export default {
  components: { theTable },

  data() {
    return {
      columns,
    }
  },
  mounted() {},
  methods: {
    send(row) {
      if (row.loading) {
        return
      }
      this.$emit('callback', row)
    },
  },
}
</script>
